## Table 1: Summary of Requests by City

## install.packages(c("tidyverse", "scales"))
## library(tidyverse)
## library(scales)

## SET WORKING DIRECTORY HERE
## setwd()

## Loading data
## load("dta.RData")

## Table 1
city_summ = dta %>%
  group_by(city) %>%
  mutate(n = 1) %>%
  summarise(first_request = min(open_date),
            last_request = max(open_date),
            tot_requests = sum(n, na.rm = TRUE),
            tot_services = length(unique(service))) %>%
  mutate(pop_rank = c(11, 30, 24, 9, 19, 4, 2, 29, 21, 1, 6, 17, 23)) %>%
  arrange(pop_rank) %>%
  select(-pop_rank) %>%
  ungroup() %>%
  mutate(tot_requests = format(tot_requests, big.mark = ",", scientific = FALSE),
         first_request = as.character(format(as.Date(.$first_request, format = "%Y-%m-%d"), "%m/%d/%Y")),
         last_request = as.character(format(as.Date(.$last_request, format = "%Y-%m-%d"), "%m/%d/%Y")))

names(city_summ) = c("City", "First Request",
                     "Last Request", "# of Requests", "# of Service Areas")
